Exploit the vulnerable login system
You've discovered a login portal with a critical SQL injection vulnerability. The backend query is poorly constructed and doesn't properly sanitize user input. Your mission is to bypass the authentication and retrieve the admin flag from the database.
Objective: Use SQL injection techniques to login as admin and retrieve the hidden flag.
# Vulnerable backend authentication code
def authenticate(username, password):
# VULNERABLE: String concatenation without sanitization
query = f"SELECT * FROM users WHERE username='{username}' AND password='{password}'"
result = database.execute(query)
if result:
return {
"success": True,
"user": result[0],
"message": "Login successful!"
}
else:
return {
"success": False,
"message": "Invalid credentials"
}
💡 The admin's flag is hidden in the database!